from bs4 import  BeautifulSoup
import re
from lxml import etree
file = open("C:/Users/HP/PycharmProjects/spider/test/test.html",'r',encoding='utf-8')
bs = BeautifulSoup(file,"html.parser")

# 1直接使用tag， 只能获取第一个元素
bs.h4
# 打印a下的所有属性
bs.h4.a.attrs

# 2文档遍历  / 搜索
# print(file.read())

# 字符串查找
t_list = bs.find_all('a')

#  正则表达式搜索
t_list = bs.find_all(target="_blank")



file.close()

